/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.uipositionning.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.impl.EObjectImpl;
import uimigration.UIModel.UIElement;

import uimigration.uipositionning.Positionning;
import uimigration.uipositionning.Relative;
import uimigration.uipositionning.UipositionningPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Relative</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.uipositionning.impl.RelativeImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.uipositionning.impl.RelativeImpl#getUiElement <em>Ui Element</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class RelativeImpl extends EObjectImpl implements Relative {
	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected Positionning name;
	/**
	 * The cached value of the '{@link #getUiElement() <em>Ui Element</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUiElement()
	 * @generated
	 * @ordered
	 */
	protected UIElement uiElement;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelativeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UipositionningPackage.Literals.RELATIVE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Positionning getName() {
		if (name != null && name.eIsProxy()) {
			InternalEObject oldName = (InternalEObject)name;
			name = (Positionning)eResolveProxy(oldName);
			if (name != oldName) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UipositionningPackage.RELATIVE__NAME, oldName, name));
			}
		}
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Positionning basicGetName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(Positionning newName) {
		Positionning oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UipositionningPackage.RELATIVE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIElement getUiElement() {
		return uiElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetUiElement(UIElement newUiElement,
			NotificationChain msgs) {
		UIElement oldUiElement = uiElement;
		uiElement = newUiElement;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UipositionningPackage.RELATIVE__UI_ELEMENT, oldUiElement, newUiElement);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUiElement(UIElement newUiElement) {
		if (newUiElement != uiElement) {
			NotificationChain msgs = null;
			if (uiElement != null)
				msgs = ((InternalEObject)uiElement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UipositionningPackage.RELATIVE__UI_ELEMENT, null, msgs);
			if (newUiElement != null)
				msgs = ((InternalEObject)newUiElement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UipositionningPackage.RELATIVE__UI_ELEMENT, null, msgs);
			msgs = basicSetUiElement(newUiElement, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UipositionningPackage.RELATIVE__UI_ELEMENT, newUiElement, newUiElement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UipositionningPackage.RELATIVE__UI_ELEMENT:
				return basicSetUiElement(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UipositionningPackage.RELATIVE__NAME:
				if (resolve) return getName();
				return basicGetName();
			case UipositionningPackage.RELATIVE__UI_ELEMENT:
				return getUiElement();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UipositionningPackage.RELATIVE__NAME:
				setName((Positionning)newValue);
				return;
			case UipositionningPackage.RELATIVE__UI_ELEMENT:
				setUiElement((UIElement)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UipositionningPackage.RELATIVE__NAME:
				setName((Positionning)null);
				return;
			case UipositionningPackage.RELATIVE__UI_ELEMENT:
				setUiElement((UIElement)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UipositionningPackage.RELATIVE__NAME:
				return name != null;
			case UipositionningPackage.RELATIVE__UI_ELEMENT:
				return uiElement != null;
		}
		return super.eIsSet(featureID);
	}

} //RelativeImpl
